package ar.edu.unlu.sistemas.p2p.business.vo;

import java.net.InetSocketAddress;
import java.util.StringTokenizer;

import ar.edu.unlu.sistemas.p2p.business.task.Result;
import ar.edu.unlu.sistemas.p2p.business.util.StringUtils;

public class QueryResultVO extends Result{
	
	private String file;
	private InetSocketAddress address;
	private Float rating;
	private String path;
	
	public QueryResultVO(String docName, Float value) {
		this.setDocName(docName);
		this.setValue(value);
	}
	
	public QueryResultVO(InetSocketAddress address, String docName, Float value) {
		this.setAddress(address);
		this.setDocName(docName);
		this.setValue(value);
	}
	
	public QueryResultVO(String address, String docName, Float value) {
		if (!StringUtils.esStringVacioONull(address)) {
			StringTokenizer st = new StringTokenizer(address,":");
			this.setAddress(new InetSocketAddress(st.nextToken(),Integer.parseInt(st.nextToken())));
		}
		this.setDocName(docName);
		this.setValue(value);
	}
	
	public InetSocketAddress getAddress() {
		return address;
	}

	public void setAddress(InetSocketAddress address) {
		this.address = address;
	}
	
	public String getDocName() {
		return file;
	}
	public void setDocName(String docName) {
		this.file = docName;
	}
	public Float getValue() {
		return rating;
	}
	public void setValue(Float value) {
		this.rating = value;
	}
	public String getPath() {
		return this.getDocName();
	}
}
